package com.bzkj.basicinfo.mapper;

import com.bzkj.basicinfo.domain.basic.vo.PrintSkuInfoVo;
import com.bzkj.basicinfo.domain.wms.WmsStoStockEntity;
import com.bzkj.basicinfo.domain.wms.dto.FreezeDto;
import com.bzkj.basicinfo.domain.wms.dto.WmsStoStockDto;
import com.bzkj.basicinfo.domain.wms.vo.RequestStoStockVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;

/**
* @author wl
* @description 针对表【wms_sto_stock(库存表-批次商品货位)】的数据库操作Mapper
* @createDate 2025-01-02 09:51:37
* @Entity com.bzkj.basicinfo.domain.wms.WmsStoStockEntity
*/
public interface WmsStoStockMapper {

    void updateStoStock(WmsStoStockDto entity);

    void updateOutboundLimit(WmsStoStockEntity entity);

    WmsStoStockEntity finWmsStoStockOne(@Param("pkMaterial") String pkMaterial,@Param("pkBatchcode") String pkBatchcode,@Param("cwarehouseId")String cwarehouseId,@Param("cproductId")String cproductId);

    void updateStoStock1(FreezeDto dto);

    /**
     * 根据物料编码和批号获取数据
     *
     * @param vo
     * @return
     */
    WmsStoStockEntity finWmsStoStockVBatchCodeOne(RequestStoStockVo vo);

    /**
     * 根据物料主键和批号修改状态和数量
     *
     * @param entity
     */
    void update(WmsStoStockEntity entity);

    void autoFreezeTask(@Param("alarmsValues") String alarmsValues);

    /**
     * 修改QMS请验状态
     * @param tableName 表名
     * @param vo 请验实体类
     */
    int updateQmsState(@Param("tableName") String tableName, @Param("vo") RequestStoStockVo vo);

    /**
     * 查询单据号
     * @param pkMaterial 物料主键
     * @param vbatchcode 批号
     * @param cgeneralbid 单据表体主键
     */
    @Select("SELECT  BillsID FROM wms_qa_inspection WHERE  pk_material = #{pkMaterial} AND batch_no = #{vbatchcode} AND cgeneralbid = #{cgeneralbid} GROUP BY BillsID")
    String selectVbillcode(@Param("pkMaterial") String pkMaterial,
                           @Param("vbatchcode") String vbatchcode,
                           @Param("cgeneralbid") String cgeneralbid);

    /**
     * 采购入
     */
    WmsStoStockEntity findWmsInDetailMaterial(PrintSkuInfoVo vo);

    /**
     * 其他入
     */
    WmsStoStockEntity findWmsInDetailOther(PrintSkuInfoVo vo);

    /**
     * 其他出
     */
    WmsStoStockEntity findWmsOutDetailOther(PrintSkuInfoVo vo);

    /**
     * 材料出
     */
    WmsStoStockEntity findWmsOutMaterial(PrintSkuInfoVo vo);

    /**
     * 转库
     */
    WmsStoStockEntity findWmsMoveDetailOrder(PrintSkuInfoVo vo);

    WmsStoStockEntity findWmsProductDetailOrder(PrintSkuInfoVo vo);

    /**
     * 根据货位id获取库存数据
     *
     * @param stoUnitId
     * @return
     */
    List<WmsStoStockEntity> findWmsStoStockByStoUnitId(@Param("stoUnitId") String stoUnitId);

    //==============批发版本相关接口==============

    /**
     * 批发库存查询
     * @param dto
     * @return
     */
    List<HashMap<String,Object>> selectAllStoStock(WmsStoStockDto dto);
    /**
     * 批发库存新增
     * @param dto
     * @return
     */
    int insertStoStock(WmsStoStockDto dto);
    /**
     * 批发库存更新
     * @param dto
     * @return
     */
    int updatePFStoStock(WmsStoStockDto dto);
    /**
     * 批发库存状态修改
     * @param
     * @return
     */
    int updateEnableStateById(@Param("state")String state,@Param("id")String id);
    /**
     * 批发库存删除
     * @param
     * @return
     */
    int deleteById(@Param("id")String id);

    /**
     * 根据商品id删除商品所有批次的信息
     * @param productId
     * @return
     */
    int deleteByproductId(@Param("productId")String productId);

}




